package com.baihan.angus.app.game.busshow.ui.script_library;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.baihan.angus.app.game.basic.base.view_model.BaseViewModel;
import com.baihan.angus.app.game.basic.utils.Tooast;
import com.baihan.angus.app.game.basic.utils.net.ApiObserver;
import com.baihan.angus.app.game.common.bean.response.ScriptRankResponse;
import com.baihan.angus.app.game.common.data_center.remote.RemoteDataMng;

import java.util.List;
import java.util.Map;

public class ScriptDepotVM extends BaseViewModel {

    public ScriptDepotVM(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<List<ScriptRankResponse.Data>> mldRankList = new MutableLiveData<>();

    public void getScriptRankList(Map<String, Object> pMap) {
        showLoading("getScriptRankList");
        RemoteDataMng.getInstance().getScriptRankList(pMap, mLifecycleProvider.bindToLifecycle(), new ApiObserver<ScriptRankResponse>() {
            @Override
            public void onSuccess(ScriptRankResponse scriptRankResponse) {
                hideLoading("getScriptRankList");
                mldRankList.setValue(scriptRankResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                hideLoading("getScriptRankList");
                mldRankList.setValue(null);
                Tooast.normalInfo(msg);
            }
        });
    }
}
